const { mysql } = require('../qcloud')

module.exports = async ctx => {

  var url = ctx.request.url;

  var message = url.substring(url.indexOf('?') + 9, url.lastIndexOf('&'));
  var nickName = url.substring(url.lastIndexOf('&')+10);
  
  // 插入消息
  var myDate = new Date();
  var feedback = {
    content: decodeURI(message),
    nickname: decodeURI(nickName),
    datetime: myDate.toLocaleString()
  }
  await mysql("feedback").insert(feedback);

  ctx.state.data = ctx
  
}